package tech.yangzhijie.login.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.yangzhijie.login.mapper.MenuVoMapper;
import tech.yangzhijie.login.pojo.TMenu;
import tech.yangzhijie.login.service.MenuService;
import tech.yangzhijie.login.vo.EasyUiTree;
import tech.yangzhijie.login.vo.UserVo;


@Service
public class MenuServiceImpl implements MenuService {

	@Autowired
	private MenuVoMapper menuVoMapper;
	
	@Override
	public List<EasyUiTree> findMenuList(UserVo userVo) {
		List<TMenu> mlist = menuVoMapper.findMenuList(userVo);
		List<EasyUiTree> elist = new ArrayList<>();
		for (TMenu tmenu : mlist) {
			EasyUiTree tree = new EasyUiTree();
			tree.setId(tmenu.getMid());
			tree.setText(tmenu.getMname());
			tree.setUrl(tmenu.getUrl());
			tree.setState(tmenu.getIsparent()==1?"closed":"open");
			elist.add(tree);
		}
		return elist;
	}

}
